

let myMeetingList = [
    {
        post: "",
        title: "小儿感冒课题会议1",
        date: "2021-02-11 14:30~15:00",
        num: 22,
        trtcRoomId: 872924742,
        status: 1,
        masterId: 'userA'
    },
    {

        post: "",
        title: "小儿感冒课题会议1",
        date: "2021-02-11 14:30~15:00",
        num: 22,
        trtcRoomId: '@TGS#aM2YD4BHJ',
        status: 2,
        masterId: 'userA'
    }

    // {
    //     post: "",
    //     title: "小儿感冒课题会议1",
    //     date: "2021-02-11 14:30~15:00",
    //     num: 22,
    //     trtcRoomId: 872924742,
    //     status: "2",
    // },
    // {
    //     post: "",
    //     title: "小儿感冒课题会议1",
    //     date: "2021-02-11 14:30~15:00",
    //     num: 22,
    //     trtcRoomId: 872924742,
    //     status: "2",
    // },
    // {
    //     post: "",
    //     title: "小儿感冒课题会议1",
    //     date: "2021-02-11 14:30~15:00",
    //     num: 22,
    //     trtcRoomId: 872924742,
    //     timer: 500,
    //     status: "1",
    // },
    // {
    //     post: "",
    //     title: "小儿感冒课题会议2",
    //     date: "2021-02-11 14:30~15:00",
    //     num: 22,
    //     trtcRoomId: 872924742,
    //     timer: 500,
    //     status: "1",
    // },
];
let historyList = [
    {
        post: "",
        title: "小儿感冒课题会议2",
        date: "2021-02-11 14:30~15:00",
        num: 22,
        status: "已结束",
        duration: "120",
        trtcRoomId: 872924742,
        status: "4",
    },
    {
        post: "",
        title: "小儿感冒课题会议2",
        date: "2021-02-11 14:30~15:00",
        num: 22,
        trtcRoomId: 777777,
        status: "872924742",
        duration: "120",
        status: "4",
    },
];
const getRoomInfo = function (req, res) {
    console.log('获取房间信息', req.query.roomId)
    let data = {};
    let roomId = req.query.roomId;
    for (let i in myMeetingList) {
        if (roomId == myMeetingList[i].trtcRoomId) {
            data = myMeetingList[i];
            break;
        }
    }
    res.json(data);
};
const getRoomList = function (req, res) {
    // 获取房间列表
    let data = {
        myMeetingList,
        historyList
    }
    res.json(data);
};
const UpdateRoomStatus = function (req, res) {
    // 修改房间状态
    console.log('修改房间状态', req.body)
    let data = {};
    let roomId = req.body.roomId;
    let status = req.body.status;
    for (let i in myMeetingList) {
        if (roomId == myMeetingList[i].trtcRoomId) {
            myMeetingList[i].status = status;
            data = myMeetingList[i];
            break;
        }
    }
    res.json(data);
};


module.exports = {
    getRoomInfo,
    getRoomList,
    UpdateRoomStatus
}